package com.freeme.cameraplugin.watermarkmode.ui;  
  
import com.freeme.cameraplugin.watermarkmode.R;

import android.app.Dialog;  
import android.content.Context;  
import android.os.Bundle;  
import android.util.Log;
import android.view.Gravity;  
import android.view.LayoutInflater;  
import android.view.ViewGroup;  
import android.view.WindowManager.LayoutParams;  
  
  
/** 
 * 对话框基类 
 *  
 * @author Allen.li 
 *  
 */  
public class BaseDialog extends Dialog{  
    private Context context;  
    private LayoutInflater inflater;  
    private ViewGroup view;
	private Context mPluginContext;  
    public BaseDialog(Context context,Context pluginContext) {  
//      super(context);  
        super(context,pluginContext.getResources().getIdentifier("dialog", "style", pluginContext.getPackageName()));  
       
        this.context = context;  
        mPluginContext = pluginContext;
    }  
      
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        Log.i("BaseDialog", mPluginContext.getPackageName());
        setCanceledOnTouchOutside(false);//点击对话框外禁止取消窗口  
        LayoutParams params = getWindow().getAttributes();  
        params.width = 400;
        params.height = 400;
        getWindow().setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);  
        getWindow().setAttributes(  
                (android.view.WindowManager.LayoutParams) params);  
          
        this.inflater = getLayoutInflater();  
        view = (ViewGroup) LayoutInflater.from(mPluginContext).inflate(R.layout.test, null);  
        setContentView(view);  
        view.setFocusable(true);  
        view.setFocusableInTouchMode(true);  
        view.requestFocus();  
        setCancelable(true);
        setCanceledOnTouchOutside(true);
    }  
}  